@import "ui-variables";
@import "variables";

.kite-ksg {
  z-index: 500 !important;
}

kite-ksg {
  display: block;
  background-color: @overlay-background-color;
  padding: 10px;
  border-radius: @component-border-radius;
  min-width: 30rem;
  max-width: 800px;
  atom-text-editor[mini] {
    margin-bottom: 0 !important;
  }
}

kite-ksg-code-blocks {
  .kite-ksg-code-blocks-wrapper {
    overflow-y: auto;
    max-height: 70vh;

    &::-webkit-scrollbar {
      width: 0 !important;
    }
  }

  kite-ksg-loading-block {
    display: block;
    background-color: @background-color-highlight;
    display: block;
    padding: 10px;
    margin-top: 0px;
    border-radius: 0;

    .loading-spinner {
      display: inline-block;
      width: 100%;
      height: 26px;
      position: relative;
    }
    .loading-spinner:after {
      content: " ";
      position: absolute;
      display: block;
      width: 26px;
      height: 26px;
      margin: 1px;
      top: 6%;
      left: 45%;
      border-radius: 50%;
      border: 3px solid @text-color-info;
      border-color: @text-color-info transparent @text-color-info transparent;
      animation: ksg-codeblock-spin 1.2s linear infinite;
    }

    @keyframes ksg-codeblock-spin {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }
  }

  kite-ksg-code-block-group {
    display: block;
    padding: 0;
    border-radius: 0;
    margin-right: 4px;

    &.even {
      border-right: 4px @ui-site-color-2 solid;
    }

    &.odd {
      border-right: 4px @ui-site-color-3 solid;
    }

    .ksg-codeblock-group-top {
      display: flex;
      flex-direction: column;
      font-family: @font-family;
      font-size: 1.1em;
      padding-bottom: 4px;
    }

    .ksg-codeblock-group-meta {
      display: block;

      &.accepted {
        & > * {
          color: @background-color-success;
        }
      }
    }

    .ksg-codeblock-group-actions {
      display: block;
      .ksg-codeblock-group-addall {
        float: right;
        color: @text-color-info;
        text-decoration: underline;
        &:hover {
          color: @text-color-highlight;
          text-decoration: none;
          cursor: pointer;
        }
      }
    }

    .ksg-codeblock-group-title {
      font-weight: 500;

      :hover {
        color: @text-color-highlight;
        text-decoration: underline;
        cursor: pointer;
      }

      a {
        color: @text-color;
      }

      .ksg-codeblocks-title-link-icon,
      .ksg-codeblocks-title-link-icon:hover {
        color: @text-color;
        text-decoration: none;
      }
    }

    .ksg-codeblock-group-vote {
      float: right;
    }

    kite-ksg-code-block {
      font-family: var(--editor-font-family);
      font-size: 1em;
      display: block;
      margin: 5px 0;
      padding: 5px 10px;
      border-radius: 0;
      background-color: @base-background-color;
      word-wrap: break-word;
      white-space: pre-wrap;
      line-height: 1.6em;

      .ksg-code-block-toggle {
        display: block;
        font-family: @font-family;

        &:hover {
          color: @text-color-info;
        }

        .ellipsis {
          font-size: 1.7em;
        }

        .arrow {
          float: right;
          font-size: 1.7em;
        }
      }

      &.highlighted {
        background-color: @hover-background-color;
        color: @text-color-highlight;
        cursor: pointer;
      }
    }

    kite-ksg-default-code-block {
      font-family: system-ui;
      font-size: 1.1em;
      display: block;
      margin: 4px 0;
      padding: 5px 10px;
      border-radius: @component-border-radius;
      background-color: @base-background-color;
      word-wrap: break-word;
      white-space: pre-wrap;
      line-height: 1.6em;

      .query {
        color: @text-color-info;
      }

      &.highlighted {
        background-color: @hover-background-color;
        color: @text-color-highlight;
        cursor: pointer;
      }
    }
  }
}

kite-ksg-search {
  display: block;
  margin-bottom: @component-border-radius;

  span.ksg-kite-logo {
    content: "";
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    mask-image: url("atom://kite/assets/logo-completions.svg");
    -webkit-mask-image: url("atom://kite/assets/logo-completions.svg");
    mask-size: contain;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    -webkit-mask-repeat: no-repeat;
    background-color: @text-color;
    margin: auto;
    margin-right: 5px;
  }

  .loading-spinner-wrapper {
    position: relative;
    padding-right: 5px;
    margin: auto;
  }
  .loading-spinner {
    border: 2px solid @text-color-subtle;
    border-top: 2px solid @text-color-info;
    border-radius: 50%;
    width: 1em;
    height: 1em;
    animation: spin 2s linear infinite;
  }

  @keyframes spin {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
  kite-ksg-search-results {
    position: relative;
    border: none;
    border-radius: @component-border-radius;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    display: block;

    &.bordered {
      border: 2px solid @border-color;
      border-top: none;
    }
  }

  kite-ksg-default-search-result,
  kite-ksg-search-result {
    color: @text-color;
    display: block;

    padding-left: 0.5em;

    font-size: 1.25em;
    line-height: 1.75em;
    font-family: system-ui;

    &.highlight-result {
      background-color: @hover-background-color;
      color: @text-color-highlight;
      cursor: pointer;
    }

    .plain-text {
      font-family: @font-family;
      color: @text-color-subtle;
    }

    .ksg-search-result-remainder {
      font-weight: 700;
    }
  }
}

.ksg-search-error {
  color: red;
  font-size: 8px;
  padding-top: 1em;
}

.ksg-shortcut {
  display: inline-block;
  width: 34px;
  height: 30px;
  position: relative;
  so-logo.badge {
    background: none;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -13px 0 0 -12px;
  }
  so-logo img {
    width: 12px;
    height: 12px;
  }
}
